home *** CD-ROM | disk | FTP | other *** search
- /* XDataUtil.h
- *
- * The data manipulation utilities. I wrote my own because I'm
- * one of those obnoxious types who likes to know what's going on.
- *
- * Copyright (C) 1997 by William Edward Woody and In Phase Consulting,
- * all rights reserved.
- */
-
- /* YAAF - Yet another application framework
- * Copyright (C) 1997 William Edward Woody and In Phase Consulting
- *
- * This library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Library
- * General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or any
- * later version.
- *
- * This library is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Library General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * To contact the author, either e-mail me at
- * woody@alumni.caltech.edu, or write to us at
- *
- * William Edward Woody
- * In Phase Consulting
- * 1545 Ard Eevin Avenue
- * Glendale, CA 91202
- */
-
- #ifndef __XDATAUTIL_H__
- #define __XDATAUTIL_H__
-
- #ifndef __XCONFIG_H__
- #include <XConfig.h>
- #endif
-
- #if defined(__MWERKS__)
- #if defined(macintosh)
- #pragma options align=power
- #endif
- #if defined(__INTEL__)
- #pragma pack(push,2)
- #endif
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
-
- /************************************************************************/
- /* */
- /* short/long compression */
- /* */
- /************************************************************************/
-
- #define MAKEDWORD(x,y) ((((long)(x)) << 16) | ((long)(y)))
- #define GETLOWORD(x) ((short)((x)&0xFFFF))
- #define GETHIWORD(x) ((short)((x) >> 16))
-
- /************************************************************************/
- /* */
- /* String Conversion */
- /* */
- /************************************************************************/
-
- extern unsigned char *cvtc2p(unsigned char *, const char *);
- extern char *cvtp2c(char *, const unsigned char *);
-
- /************************************************************************/
- /* */
- /* Pascal string manipulation */
- /* */
- /************************************************************************/
-
- extern unsigned char *pstrcpy(unsigned char *, const unsigned char *);
- extern unsigned char *pstrcat(unsigned char *, const unsigned char *);
- extern long pstrcmp(const unsigned char *, const unsigned char *);
-
- /************************************************************************/
- /* */
- /* Endian byte order utilities */
- /* */
- /************************************************************************/
-
- /*
- * Byte order swap
- */
-
- extern unsigned short SwapWord(unsigned short);
- extern unsigned long SwapLong(unsigned long);
- extern float SwapFloat(float);
- extern double SwapDouble(double);
-
- /*
- * Conversion to/from network order
- */
-
- #if OPT_NATIVEORDER == 1
-
- #define ESwapWord(x) SwapWord(x)
- #define ESwapLong(x) SwapLong(x)
- #define ESwapFloat(x) SwapFloat(x)
- #define ESwapDouble(x) SwapDouble(x)
-
- #define NSwapWord(x) (x)
- #define NSwapLong(x) (x)
- #define NSwapFloat(x) (x)
- #define NSwapDouble(x) (x)
-
- #else
-
- #define NSwapWord(x) (x)
- #define NSwapLong(x) (x)
- #define NSwapFloat(x) (x)
- #define NSwapDouble(x) (x)
-
- #define ESwapWord(x) SwapWord(x)
- #define ESwapLong(x) SwapLong(x)
- #define ESwapFloat(x) SwapFloat(x)
- #define ESwapDouble(x) SwapDouble(x)
-
- #endif
-
-
- #ifdef __cplusplus
- }
- #endif
-
- #if defined(__MWERKS__)
- #if defined(macintosh)
- #pragma options align=reset
- #endif
- #if defined(__INTEL__)
- #pragma pack(pop)
- #endif
- #endif
-
- #endif /* __XDATAUTIL_H__ */
-